package com.oneday.nuo.base.controller;


import com.oneday.nuo.base.entity.NuoRoleEntity;
import com.oneday.nuo.base.response.NuoResult;
import com.oneday.nuo.base.service.NuoRoleAuthService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


/**
 * (NuoRoleAuth)表控制层
 *
 * @author liushuai
 * @since 2021-03-13 23:37:32
 */
@RestController
@RequestMapping("api/role/auth")
@Api(tags = "NuoRoleAuthController")
public class NuoRoleAuthController {
    @Autowired
    private NuoRoleAuthService nuoRoleAuthService;


    @ApiOperation(value = "保存角色和权限关联关系" ,  notes="保存角色和权限关联关系")
    @PostMapping("saveRoleAuth")
    public NuoResult<List<NuoRoleEntity>> saveRoleAuth(@RequestBody  Map<String,Object> param){
        nuoRoleAuthService.saveRoleAuth(param);
        return NuoResult.buildResponseSave();
    }
    @ApiOperation(value = "根据角色id获取权限列表" ,  notes="根据角色id获取权限列表")
    @GetMapping("queryAuthIdsByRoleId")
    public NuoResult<List<String>> queryAuthIdsByRoleId(@RequestParam("roleId") String roleId){
       List<String> ids =  nuoRoleAuthService.queryAuthIdsByRoleId(roleId);
        return NuoResult.buildResponseQuery(ids);
    }




}